feat(iOS, FormSheet v5): Add basic setup for standalone FormSheet native component#3947
Open
feat(iOS, FormSheet v5): Add basic setup for standalone FormSheet native component#3947
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introducing the iOS implementation of the standalone FormSheet component.
Key Architectural Decisions:
UIModalPresentationFormSheetpresentation.RNSFormSheetHostController. This controller creates a transparent top-level UIView and is presented modally over the current UIWindow hierarchy via the closest validpresentingViewController.isOpenprop. This declarative boolean is translated into imperativepresentViewControlleranddismissViewControllercalls. When a user natively dismisses the sheet (e.g., via a swipe-down gesture), theRNSFormSheetHostControllerDelegatetriggers theRNSFormSheetHostComponentEventEmitterto fire theonNativeDismissevent, allowing the JS to synchronize its local state.viewDidLayoutSubviewsinside the presented controller. When the native bounds change, the new size and origin offset are captured and dispatched via a C++ state update. This explicitly forces Yoga to synchronously recalculate the content layout using the sheet's actual native dimensions.RNSFormSheetHostContentView.Implementation details:
RCTSurfaceTouchHandlerattached to the controller's view, utilizingviewOriginOffsetto correctly align the React touch coordinate space with the natively presented window.Caution
Dynamic content origin updates aren't supported in the context of synchronization with the ShadowTree state. If an ancestor offset changes, the frame of our Host view might not be updated at all, because from the Host perspective, the frame doesn't change, so there's no need to re-layout the content.
Changes
RNSFormSheetHostComponentViewto handle the Fabric lifecycle.RNSFormSheetHostControllerto manage modal presentation.RNSFormSheetHostContentViewto isolate react subviews reparenting.RNSFormSheetHostComponentEventEmitterand updated the JS spec to emit theonNativeDismissevent.RNSFormSheetHostShadowNodedefinitions for synchronous layout updates via C++ state proxy.Before & after - visual documentation
basic-layout.mov
formsheet-with-stack-v5.mov
Test plan
isOpenis set totrue.StackContainerfills the FormSheet's boundsChecklist